//
//  YYBarButtonItem.swift
//  新浪微博
//
//  Created by fdq on 16/7/19.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

class YYBarButtonItem: UIBarButtonItem {

	 init(title: String?,imgName: String?, target: AnyObject?, action: Selector ) {
		super.init()
		
		let button = UIButton()
		//判断,如果是文字
		if let tit = title{
			
			button.setTitle(tit, forState: UIControlState.Normal)
			button.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
			button.titleLabel?.font = UIFont.systemFontOfSize(15)
		}
		//如果是图片
		if let img = imgName{
			button.setImage(UIImage(named: img), forState: UIControlState.Normal)
		}
		
		button.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
		
		button.sizeToFit()
		self.customView = button
		
	}

	required init?(coder aDecoder: NSCoder) {
	    fatalError("init(coder:) has not been implemented")
	}
	
}
